package ck.mmd.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

public class ActiveCodeAction {
	public String active(){
		try {
			//UserService userservice = new UserService();
			HttpServletRequest request = ServletActionContext.getRequest();
			
			//1.获取激活码
			String activecode = request.getParameter("activecode");
			//2.调用service中的方法激活
			//boolean str = userservice.active(activecode);
			boolean str = true;
			if(str==true){
				//4.激活成功，回到message视图
				request.setAttribute("message", "激活账户成功,请登录");
				request.setAttribute("url", "tologin");
				request.setAttribute("message2", "去登录");
				return "success";
			}
			request.setAttribute("message", "激活失败！用户已经激活，请直接登录！");
			request.setAttribute("url", "/study");
			request.setAttribute("message2", "回到主页");
			return "error";
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException("激活失败");
		}	
	}
}
